
package dao;

import database.DataBase;
import interfaces.FirmaInterface;
import java.rmi.RemoteException;
import java.sql.ResultSet;
import java.sql.SQLException;
import model.Firma;

public class Firma_DAO {

    private DataBase conn;

    public Firma_DAO() {
        this.conn = DataBase.getInstance();
        //test
    }

    /* Varegrupp rabatter .. */
    /**
     * @param userName
     */
    public FirmaInterface hentFirma(String userName) throws SQLException, RemoteException {
        Firma firma = null;
        
        ResultSet rs = null;
        
        /* Hent alle vare grupper */
        String sql = "call `hent firma`('" + userName + "');";
        
        System.out.println("sql   " + sql);
        rs = conn.getResult(sql);
        while (rs.next()) /* Hent samtlige varegrupper .. */ {
            firma = new Firma( rs.getString("navn"), rs.getDouble("konto")  );             
        }

        return firma;
    }
}
